<?php
namespace app\admin\model;

use think\Db;
use think\Model;

class Login extends Model{
    protected $table = 'am_user';

    //查找用户信息
    public function find($name)
    {
        $result = $this->field('')->where("username='$name'")->find();
        return $result;
    }

    //更新用户登录信息
    public function updateLoginInfo($id,$ip,$time)
    {
        $this->save([
            'last_login_ip'=>$ip,
            'last_login_time'=>$time
            ],['id'=>$id]);
    }

    //记录登录失败次数
    public function getLoginFalse($id)
    {
        $num = $this->field('login_count')->where("'id='.$id")->find();
        return $num;
    }

    //更新登录失败的次数
    public function updateLoginFalse($id,$num)
    {
        $this->save(['login_count'=>$num],['id'=>$id]);
    }
}